import {
	getToken,
} from './utils/cookies'
import router from './router'
import store from './store'
// 加载条
import NProgress from "nprogress";
import "nprogress/nprogress.css";
// 
// import install from "@/utils/request"
NProgress.configure({
	showSpinner: true
}); // 显示右上角螺旋加载提示

// import routerArr from './store/router' //假菜单
const whiteList = ['/login', '/register', '/forgotpassword']

router.beforeEach(async (to, from, next) => {
	document.title = to.meta.title
	// console.log(to.meta.title)
	NProgress.start();
	const token = getToken()
	if (token) {
		// console.log(install.install.app.config.globalProperties)
		next()
	} else {
		if (whiteList.indexOf(to.path) !== -1) {
			next()
		} else {
			next('/login')
			NProgress.done()
		}
	}
})
router.afterEach(() => {
	NProgress.done()
})